#ifndef AUDIODIALOG_H
#define AUDIODIALOG_H

#include <QtGui>
#include <qtopiaapplication.h>
#include <QMouseEvent>

#include "ui_audiodialogform.h"
#include "audiomanager.h"

class AudioDialog : public QWidget, public Ui_AudioDialog
{
	Q_OBJECT

	public:
		AudioDialog( QWidget *parent=0, Qt::WFlags f = 0 );
        ~AudioDialog();
		void setAudio(QString audioname, int offset);
		
	private:
		AudioManager *audioManager;
		bool isPlaying;
		bool pause;
		int offset;
		int duration; // in second

		void addIcon(QPushButton *button, QString filename);
		QString timeFormat(int time);
		void updateView(int offset);

		bool isAudioPlayingListenerEnabled;
		int interval;
		bool eventFilter(QObject *watched, QEvent *event);
		
	signals:
		void setOffsetSignal(int offset);
		void cancelSignal();
		
	public slots:
		void on_playPushButton_clicked();
	    void on_stopPushButton_clicked();
	    void on_rewindPushButton_clicked();
	    void on_forwardPushButton_clicked();
        void on_savePushButton_clicked();
        void on_cancelPushButton_clicked();

 		void on_slider_valueChanged(int value);
        void on_slider_sliderPressed();
        void on_slider_sliderReleased();
        void audioPlayingListener(int time);
        void audioFinishingListener();
		
		void closeListener();
};

#endif
